<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <script type="text/javascript">
    class Primitivestring {
      static [Symbol.hasInstance](x) {
        return typeof x === 'string'
      }
    }
    console.log('hello world' instanceof Primitivestring)

    let a = {
      valueOf() {
        return 0
      },
      toString() {
        return '1'
      },
      [Symbol.toPrimitive]() {
        return 2
      }
    }
    console.log(1 + a) // => 3

    // 直接调用 `this` 指的是 `window`
    function foo() {
      console.log(this.a)
    }
    var a = 1
    foo()
    // obj.foo() this 指的是obj对象
    const obj = {
      a: 2,
      foo: foo
    }
    obj.foo()
    // this 被绑定到 c 上 不会被任何形式改变
    const c = new foo()
  </script>
</body>
</html>